<template>
  <div class='container'>

    <el-form :model="audit" :rules="rules" ref="audit">
      <el-form-item>
        <el-radio v-model="audit.chkState" :label="1">通过</el-radio>
        <el-radio v-model="audit.chkState" :label="2">拒绝</el-radio>
      </el-form-item>
      <el-form-item prop="chkRemarks">
        <el-input type="textarea" :rows="2" placeholder="请输入审核意见" v-model="audit.chkRemarks">
        </el-input>
      </el-form-item>
    </el-form>
    <el-row type="flex" justify="end" style="margin-top:50px">
      <el-button size="small" @click="$emit('close')">取消</el-button>
      <el-button type="primary" size="small" @click="hSubmit">确认</el-button>
    </el-row>
  </div>
</template>

<script>
import { choiceCheck } from '../../api/hmmm/questions'
export default {
  props: {
    auditId: {
      type: Number,
      required: true
    }
  },
  data () {
    return {
      audit: {
        id: this.auditId,
        chkState: 1,
        chkRemarks: ''
      },
      rules: {
        chkRemarks: [
          { required: true, message: '请输入审核意见', trigger: 'blur' }
        ]

      }
    }
  },
  methods: {
    // 审核试题
    async hSubmit () {
      const valid = await this.$refs.audit.validate().catch(e => { })
      if (!valid) return
      try {
        await choiceCheck(this.audit)
        this.$message.success('审核成功')
        this.$emit('success')
        this.$emit('close')
      } catch (e) {
        this.$message.error('审核失败')
      }
    }
  }
}
</script>

<style scoped lang='less'></style>
